package com.example.indenture.config;


import com.example.indenture.common.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * 全局配置文件
 *
 * @author CY
 * @date 2023/03/14 21:06
 **/
@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        final InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginInterceptor);
        interceptorRegistration.addPathPatterns("/**");
        List<String> list = new ArrayList<String>() {
            {
                add("/api/user/insert");
                add("/api/user/login");

                add("/api/company/insert");
                add("/api/company/login");
                add("/alipay/pay");
                add("/alipay/notify");

            }
        };
        interceptorRegistration.excludePathPatterns(list);
    }
}
